module.exports = {

    /** @param {Creep} creep **/
    run: function (creep) {
        var target = creep.pos.findClosestByRange(FIND_HOSTILE_CREEPS);
        if (target) {
            var enemy = 0;
            creep.rangedAttack(target);
            for (var body in target.body) {
                if (target.body[body].type == ATTACK ||
                    target.body[body].type == RANGED_ATTACK ||
                    target.body[body].type == CLAIM) {
                    enemy++;
                    if (target.pos.x > 24 && target.pos.y > 42) {
                        if (!creep.pos.isEqualTo(30, 42)) {
                            creep.moveTo(creep.room.getPositionAt(30, 42), {
                                visualizePathStyle: { stroke: 'rgb(230, 18, 18)' }
                            });
                        }
                        break;
                    }
                    if (creep.rangedAttack(target) == ERR_NOT_IN_RANGE) {
                        creep.moveTo(target, { visualizePathStyle: { stroke: 'rgb(230, 18, 18)' } });
                    }
                }
            }
            if (!enemy) {
                if (!creep.pos.isEqualTo(29, 43)) {
                    creep.moveTo(creep.room.getPositionAt(29, 43));
                }
                creep.say('hello');
            }
        }
        else if (!creep.pos.isEqualTo(29, 43)) {
            creep.moveTo(creep.room.getPositionAt(29, 43), {
                visualizePathStyle: { stroke: 'rgb(230, 18, 18)' }
            });
        }
    }
};